import type { IOrg, IOrgBizType, IOrgMgmt, ITablePagination, PList, POrgLoad } from '@/types/bo/OrgBo';
import http from '@/utils/RequestUtils';

export function onOrgLoad(data: POrgLoad) {
  return http.post<IOrg[]>(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/load`, data);
}

export function getOrgInfo(data: IOrg) {
  return http.get<IOrg[]>(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/detail`, data);
}

export function onOrgCreate(data: IOrg) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/add`, data);
}

export function onOrgUpdate(data: IOrg) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/update`, data);
}

export function fetchOrgBizList(data: PList) {
  return http.post<ITablePagination>(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/biz/list`, data);
}

export function fetchMgmtList(data: PList) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/mgmts/list`, data);
}

export function onMgmtCreate(data: IOrgMgmt) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org/mgmts/add`, data);
}

export function onMgmtUpdate(data: IOrgMgmt) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org-mgmt/update`, data);
}

export function updateMgmtState(data: IOrgMgmt) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/org-mgmt/status`, data);
}

export function fetchOrgTypeList(data: PList) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/biz-type/list`, data);
}

export function onOrgTypeCreate(data: IOrgBizType) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/biz-type/add`, data);
}

export function onOrgTypeUpdate(data: IOrgBizType) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/biz-type/update`, data);
}

export function updateOrgTypeState(data: IOrgBizType) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/biz-type/status`, data);
}

export function getCommonData(data: POrgLoad) {
  return http.post(`${import.meta.env.VITE_API_BASE_FOUNDATION}/api/dict-query/v1/items/page`, data);
}
